//
//  XSJVisitorTableViewController.swift
//  weiBo项目准备
//
//  Created by 鲜世杰 on 16/5/11.
//  Copyright © 2016年 鲜世杰. All rights reserved.
//

import UIKit

class XSJVisitorTableViewController: UITableViewController {
    //    var userLogin = false
    var userLogin = XSJUserAccountViewModel.sharedUserAccount.isLogin
   
    var visitorView: XSJVisitor?
    
    override func loadView() {
        if userLogin {
            super.loadView()
        }else
        {
            visitorView = XSJVisitor()
            //
            visitorView!.callBackClosure = { [weak self] in
                print("哈哈")
//                print(self)
                self?.requestOAuthLogin()
            }
            view = visitorView
            setupNavUI()
        }
    }
    private func setupNavUI() {
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", fontSize: 15, target: self, action: "registerAction")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", fontSize: 15, target: self, action: "loginAction")
        
        
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        
    }
    
    @objc private func registerAction () {
        requestOAuthLogin()
    }
    @objc private func loginAction () {
        requestOAuthLogin()
    }
    
    private func requestOAuthLogin (){
        
        let oauthVC = XSJOAuthViewController()
        let nav = UINavigationController(rootViewController: oauthVC)
        presentViewController(nav, animated: true, completion: nil)
        
    }
    
    
   

}
